﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xrm.Sdk.Client;
using DataFlock.CRM.Engine.Common;
using DataFlock.CRM.Engine.SDK;

namespace DataFlock.CRM.Engine
{
    internal class Context: IDisposable
    {
        private static OrganizationServiceProxy _serviceProxy;

        internal static OrganizationServiceProxy GetServiceProxy()
        {
            _serviceProxy = new OrganizationServiceProxy(Organization.OrganizationService, Organization.HomeRealmUri, Security.Credentials, Security.DeviceCredentials);
            _serviceProxy.EnableProxyTypes();
            return _serviceProxy;
        }

        public void Dispose()
        {
            _serviceProxy.Dispose();
        }
    }
}
